import random
import string
from .course_task_classes import Course


def generate_course_id(prefix: str = "CS") -> str:
    #生成唯一课程ID
    numbers = random.randint(100, 999)
    suffix = ''.join(random.choices(string.ascii_uppercase + string.digits, k=4))
    return f"{prefix}{numbers}-{suffix}"

def display_students(students):
    """显示学生列表"""
    print("Student List:")
    for i, student in enumerate(students, 1):
        print(f"  {i}. {student.username}(ID:{student.student_id})")


def print_course_details(course: Course) -> None:
    #打印课程详细信息(含学生和作业列表)
    print("\n" + "="*50)
    print(f"Course detail:{course}")
    print(f"Course descripe:{course._description if course._description else 'None'}")
    
    print("\nSelected student")
    for i, student in enumerate(course.get_enrolled_students(), 1):
        print(f"  {i}. {student.name}(ID:{student.student_id})")
    
    print("\nCourse homework")
    for i, assignment in enumerate(course._course_assignments, 1):
        print(f"  {i}. {assignment.title}(Deadline:{assignment.due_date})")
    print("="*50 + "\n")